/*     */ package com.zimbra.cs.security.sasl;
/*     */ 
/*     */ import javax.security.sasl.SaslClient;
/*     */ import javax.security.sasl.SaslException;
/*     */ import javax.security.sasl.SaslServer;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public abstract class SaslSecurityLayer
/*     */ {
/*     */   public static final String QOP_AUTH = "auth";
/*     */   public static final String QOP_AUTH_INT = "auth-int";
/*     */   public static final String QOP_AUTH_CONF = "auth-conf";
/*     */   public static final int MAX_SEND_SIZE = 4096;
/*     */   public static final int MAX_RECV_SIZE = 65536;
/*     */   
/*     */   public static SaslSecurityLayer getInstance(SaslClient client)
/*     */   {
/*  41 */     new SaslSecurityLayer() {
/*     */       public String getMechanismName() {
/*  43 */         return this.val$client.getMechanismName();
/*     */       }
/*     */       
/*  46 */       public Object getNegotiatedProperty(String name) { return this.val$client.getNegotiatedProperty(name); }
/*     */       
/*     */       public byte[] wrap(byte[] b, int off, int len) throws SaslException {
/*  49 */         return this.val$client.wrap(b, off, len);
/*     */       }
/*     */       
/*  52 */       public byte[] unwrap(byte[] b, int off, int len) throws SaslException { return this.val$client.unwrap(b, off, len); }
/*     */       
/*     */       public void dispose() throws SaslException {
/*  55 */         this.val$client.dispose();
/*     */       }
/*     */     };
/*     */   }
/*     */   
/*     */   public static SaslSecurityLayer getInstance(SaslServer server) {
/*  61 */     new SaslSecurityLayer() {
/*     */       public String getMechanismName() {
/*  63 */         return this.val$server.getMechanismName();
/*     */       }
/*     */       
/*  66 */       public Object getNegotiatedProperty(String name) { return this.val$server.getNegotiatedProperty(name); }
/*     */       
/*     */       public byte[] wrap(byte[] b, int off, int len) throws SaslException {
/*  69 */         return this.val$server.wrap(b, off, len);
/*     */       }
/*     */       
/*  72 */       public byte[] unwrap(byte[] b, int off, int len) throws SaslException { return this.val$server.unwrap(b, off, len); }
/*     */       
/*     */       public void dispose() throws SaslException {
/*  75 */         this.val$server.dispose();
/*     */       }
/*     */     };
/*     */   }
/*     */   
/*     */   public abstract String getMechanismName();
/*     */   
/*     */   public abstract Object getNegotiatedProperty(String paramString);
/*     */   
/*     */   public abstract byte[] wrap(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
/*     */     throws SaslException;
/*     */   
/*     */   public abstract byte[] unwrap(byte[] paramArrayOfByte, int paramInt1, int paramInt2) throws SaslException;
/*     */   
/*     */   public abstract void dispose() throws SaslException;
/*     */   
/*     */   public boolean isEnabled()
/*     */   {
/*  93 */     String qop = (String)getNegotiatedProperty("javax.security.sasl.qop");
/*  94 */     return (qop != null) && (("auth-int".equals(qop)) || ("auth-conf".equals(qop)));
/*     */   }
/*     */   
/*     */   public int getMaxSendSize() {
/*     */     try {
/*  99 */       String s = (String)getNegotiatedProperty("javax.security.sasl.rawsendsize");
/* 100 */       return Integer.parseInt(s);
/*     */     } catch (Exception e) {}
/* 102 */     return 4096;
/*     */   }
/*     */   
/*     */   public int getMaxRecvSize()
/*     */   {
/*     */     try {
/* 108 */       String s = (String)getNegotiatedProperty("javax.security.sasl.maxbuffer");
/* 109 */       return Integer.parseInt(s);
/*     */     } catch (Exception e) {}
/* 111 */     return 65536;
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/security/sasl/SaslSecurityLayer.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */